/********************************************************************************
 * Project Name		[JavaSE_Fundamentals]
 * File Name     	[ArrayCopy.java]
 * Creation Date 	[2015-01-01]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ********************************************************************************/
package jdk6;

import java.util.Arrays;

/**
 * jdk 1.6新增的拷贝数组的方法<br/>
 * 
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 * 
 */
public class ArrayCopy {

	public static void arrayCopy() {
		int[] array = { 1, 2, 3, 4, 5 };
		System.out.println("array = " + Arrays.toString(array));

		int[] jdk6CopiedArray = Arrays.copyOf(array, array.length - 1);
		System.out.println("jdk 1.6 copy array = " + Arrays.toString(jdk6CopiedArray));

		// 部分拷贝[0, 3)
		int[] array2 = Arrays.copyOfRange(array, 0, 3);
		System.out.println("jdk 1.6 copy array = " + Arrays.toString(array2));
	}

	public static void main(String[] args) {
		arrayCopy();
	}
}
